//
//  OrderDetailViewController.m
//  HaierGMS_APP
//
//  Created by 堂堂 on 16/9/8.
//  Copyright © 2016年 堂堂. All rights reserved.
//

#import "OrderDetailViewController.h"
#import "AppDelegate.h"
#import "MainUITabBarController.h"
#import "UIColor+Hex.h"
#import "ProblemViewController.h"
#import "SignViewController.h"
#import "PickUpViewController.h"
#import "OppoinViewController.h"
#import "MBProgressHUD+MJ.h"

#import "AFHTTPRequestOperationManager.h"
#import "UserDefaultUtil.h"
#import "HttpReauestParam.h"
#import "UIImage+WebCache.h"
#import <MSFSDK/MSFSDK.h>
#import "FaildViewController.h"
#import "JYJViewController.h"
#import "SJAvatarBrowser.h"
#import "TicketViewController.h"
#define ScreenHeight [[UIScreen mainScreen] bounds].size.height//获取屏幕高度，兼容性测试
#define ScreenWidth [[UIScreen mainScreen] bounds].size.width//获取屏幕宽度，兼容性测试
@interface OrderDetailViewController ()

@property NSDictionary *orderd;
@property NSArray *nodeData;
@property NSInteger detailHeight;
@property NSInteger hxContent;
@property NSInteger hxResult;
@end

@implementation OrderDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    _hxContent = -1;
    self.tabBarController.tabBar.hidden = YES;
   // [self setTheScrollView:nil];
   // [self setTheBottomView];

    
}
- (int) setTheScrollView:(NSDictionary *) dic{
    
 
    UIView *childView = [self.scrollView viewWithTag:10101];
    if (childView != nil) {
        [childView removeFromSuperview];
    }
    float textSize = 13;
    int heightall = 0;
    
    UIView *scrollView_content = [[UIView alloc]init];
    scrollView_content.tag = 10101;
    //订单号
    NSString *serviceNO = [NSString stringWithFormat:@"订单号:%@",dic[@"serviceNo"]];
    UILabel *serviceNo_lab = [[UILabel alloc]init];
    float widget = [serviceNO sizeWithFont:[UIFont systemFontOfSize:textSize]].width;
    serviceNo_lab.frame = CGRectMake(6, 0, widget, 40);
    serviceNo_lab.text = serviceNO;
    serviceNo_lab.font = [UIFont systemFontOfSize:textSize];
    [scrollView_content addSubview:serviceNo_lab];
    
    //订单来源：天猫
    
    UIImage *img =[UIImage imageNamed:@"grab_order_qt"];
    
    if ([dic[@"orderFrom"] isEqualToString:@"天猫"]) {
        img =[UIImage imageNamed:@"grab_order_tm"];
    }else if ([dic[@"orderFrom"] isEqualToString:@"4PL-天猫"]) {
        img =[UIImage imageNamed:@"grab_order_tm"];
    }if ([dic[@"orderFrom"] isEqualToString:@"极有家"]) {
        img =[UIImage imageNamed:@"grab_order_jyj"];
    }else if([dic[@"orderFrom"] isEqualToString:@"京东"]){
        img = [UIImage imageNamed:@"order_order_from_jd"];
    }
    
    UIImageView *orderFrom_img = [[UIImageView alloc]init];
    orderFrom_img.frame = CGRectMake(6 + widget, 0, 40, 40);
    orderFrom_img.image = img;
    orderFrom_img.contentMode = UIViewContentModeCenter;
    [scrollView_content addSubview:orderFrom_img];
    //订单类型
    NSString *orderType = [NSString stringWithFormat:@"%@",dic[@"serviceType"]];
    UILabel *orderType_lab = [[UILabel alloc]init];
    widget = [orderType sizeWithFont:[UIFont systemFontOfSize:textSize]].width;
    orderType_lab.frame = CGRectMake(ScreenWidth - 6 - widget, 0, widget, 40);
    orderType_lab.text = orderType;
    orderType_lab.font = [UIFont systemFontOfSize:textSize];
    [scrollView_content addSubview:orderType_lab];
    //订单类型图片
    UIImageView *orderType_img = [[UIImageView alloc]init];
    orderType_img.frame = CGRectMake(ScreenWidth - 6 - widget - 40, 0, 40, 40);
    orderType_img.image = [UIImage imageNamed:@"grab_order_type"];
    orderType_img.contentMode = UIViewContentModeCenter;
    [scrollView_content addSubview:orderType_img];
    heightall = heightall + 40;
    //横线
    UIView *line0 = [[UIView alloc]initWithFrame:CGRectMake(0, heightall, ScreenWidth, 1)];
    line0.backgroundColor = [UIColor colorWithHexString:@"#f2f2f2"];
    [scrollView_content addSubview:line0];
    heightall = heightall + 1;
    //服务报价
    
    NSString *orderPrice = [NSString stringWithFormat:@"服务报价:  %@",dic[@"price"]];
    UILabel *orderPrice_lab = [[UILabel alloc]init];
    widget = [orderPrice sizeWithFont:[UIFont systemFontOfSize:textSize]].width;
    orderPrice_lab.frame = CGRectMake(6, heightall, widget, 40);
    orderPrice_lab.text = orderPrice;
    orderPrice_lab.font = [UIFont systemFontOfSize:textSize];
    [scrollView_content addSubview:orderPrice_lab];
    heightall = heightall + 40;
    //横线
    UIView *line1 = [[UIView alloc]initWithFrame:CGRectMake(0, heightall, ScreenWidth, 1)];
    line1.backgroundColor = [UIColor colorWithHexString:@"#f2f2f2"];
    [scrollView_content addSubview:line1];
    heightall = heightall + 1;
    
    //时间进度
    
    UIView *jindu = [[UIView alloc]initWithFrame:CGRectMake(0, heightall, ScreenWidth, 61)];
    [scrollView_content addSubview:jindu];
    
    NSMutableArray *timeLab = [[NSMutableArray alloc]init];
    NSMutableArray *jiedianLab = [[NSMutableArray alloc]init];
    
    NSArray *orderStatusDate = dic[@"orderStatusDate"];
    NSArray *timeArry = @[@"未服务",@"未服务",@"未服务",@"未服务"];
    NSArray *jiedianArry = @[@"已到货",@"已预约",@"已提货",@"已签收"];
    
    widget = (ScreenWidth  - 12) / 4;
    //进度中间横线
    UIView *jindu_line = [[UIView alloc]initWithFrame:CGRectMake(6, 30, ScreenWidth - 12, 1)];
    jindu_line.backgroundColor = [UIColor colorWithHexString:@"#4c4c4c"];
    
    [jindu addSubview:jindu_line];
    
    NSDateFormatter *formtter = [[NSDateFormatter alloc]init];
    for (int i = 0; i < 4; i++) {
        
        
        NSString *time = timeArry[i];
        NSString *node = jiedianArry[i];
        if (i < orderStatusDate.count) {
            
            for (int j = 0; j < orderStatusDate.count; j++) {
                NSDictionary *data = orderStatusDate[j];
                if ([node isEqualToString:data[@"status"]]) {
                    [formtter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
                    NSDate *d = [formtter dateFromString:data[@"operatingDate"]];
                    [formtter setDateFormat:@"MM.dd HH:mm"];
                    time = [formtter stringFromDate:d];
                }
            }
        }
        //时间
        UILabel *lab = [[UILabel alloc]initWithFrame:CGRectMake(i * widget + 6, 0, widget, 28)];
        lab.font = [UIFont systemFontOfSize:textSize];
        lab.text = time;
        lab.textAlignment = NSTextAlignmentCenter;
        
        [jindu addSubview:lab];
        [timeLab addObject:lab];
        
        //节点
        UILabel *lab2 = [[UILabel alloc]initWithFrame:CGRectMake(i * widget + 6, 33, widget, 28)];
        lab2.font = [UIFont systemFontOfSize:textSize];
        lab2.text = node;
        lab2.textAlignment = NSTextAlignmentCenter;
        
        [jindu addSubview:lab2];
        [jiedianLab addObject:lab];
        
        //点
        UIImageView *point_img = [[UIImageView alloc]initWithFrame:CGRectMake(i * widget, 28, widget, 5)];
        point_img.image = [UIImage imageNamed:@"order_deatail_point_image"];
        point_img.contentMode = UIViewContentModeCenter;
        [jindu addSubview:point_img];

    }
    //横线
    heightall = heightall + 60;
    UIView *line2 = [[UIView alloc]initWithFrame:CGRectMake(0, heightall, ScreenWidth, 4)];
    line2.backgroundColor = [UIColor colorWithHexString:@"#f2f2f2"];
    [scrollView_content addSubview:line2];
    heightall = heightall + 4;
    //卡券
    if(_receiveNoType == 1 || _shopNoType == 1){
        NSString *ticketTitle = @"提货信息";
        UILabel *ticketTitle_lab = [[UILabel alloc]init];
        widget = [ticketTitle sizeWithFont:[UIFont systemFontOfSize:textSize]].width;
        ticketTitle_lab.frame = CGRectMake(6, heightall , widget, 40);
        ticketTitle_lab.text = ticketTitle;
        ticketTitle_lab.font = [UIFont systemFontOfSize:textSize];
        ticketTitle_lab.numberOfLines = 2;
        [scrollView_content addSubview:ticketTitle_lab];
        //添加按钮
        UIButton *add_ticket = [[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth - 46, heightall, 40, 40)];
        [add_ticket setImage:[UIImage imageNamed:@"add_ticket"] forState:UIControlStateNormal];
        [add_ticket addTarget:self action:@selector(addTicket) forControlEvents:UIControlEventTouchUpInside];
        [scrollView_content addSubview:add_ticket];
        
        heightall = heightall + 40;
        UIView *ticketLine = [[UIView alloc]initWithFrame:CGRectMake(0, heightall, ScreenWidth, 1)];
        ticketLine.backgroundColor = [UIColor colorWithHexString:@"#f2f2f2"];
        [scrollView_content addSubview:ticketLine];
        heightall = heightall + 1;

        
        NSMutableArray *receiveNo = [[NSMutableArray alloc]init];
        NSArray *receiveNo2 = dic[@"receiveNo"];
        NSArray *shopNo = dic[@"shopNo"];

        [receiveNo addObjectsFromArray:receiveNo2];
        [receiveNo addObjectsFromArray:shopNo];
        if (receiveNo !=nil && receiveNo.count > 0) {
            
            for (int i = 0; i < receiveNo.count; i++) {
                UIImageView *img = [[UIImageView alloc]initWithFrame:CGRectMake(6, heightall, 35, 35)];
                img.image = [UIImage imageNamed:@"ticket_image"];
                img.contentMode = UIViewContentModeCenter;
                [scrollView_content addSubview:img];
                
                NSString *ticket_no = [NSString stringWithFormat:@"%@",receiveNo[i]];
                
                UILabel *ticketNo_lab = [[UILabel alloc]init];
                widget = [ticket_no sizeWithFont:[UIFont systemFontOfSize:textSize]].width;
                ticketNo_lab.frame = CGRectMake(48, heightall , widget, 35);
                ticketNo_lab.text = ticket_no;
                ticketNo_lab.font = [UIFont systemFontOfSize:textSize];
                ticketNo_lab.numberOfLines = 2;
                [scrollView_content addSubview:ticketNo_lab];
                
                heightall = heightall + 35;
                
                UIView *ticketLine2 = [[UIView alloc]initWithFrame:CGRectMake(0, heightall, ScreenWidth, 1)];
                ticketLine2.backgroundColor = [UIColor colorWithHexString:@"#f2f2f2"];
                [scrollView_content addSubview:ticketLine2];
                
                 heightall = heightall + 1;
            }

        }
        
    }
    
    //提货信息标题
    NSString *tihuoTitle = @"提货信息";
    UILabel *tihuoTitle_lab = [[UILabel alloc]init];
    widget = [tihuoTitle sizeWithFont:[UIFont systemFontOfSize:textSize]].width;
    tihuoTitle_lab.frame = CGRectMake(6, heightall , widget, 40);
    tihuoTitle_lab.text = tihuoTitle;
    tihuoTitle_lab.font = [UIFont systemFontOfSize:textSize];
    tihuoTitle_lab.numberOfLines = 2;
    [scrollView_content addSubview:tihuoTitle_lab];
    heightall = heightall + 40;
    UIView *line3 = [[UIView alloc]initWithFrame:CGRectMake(0, heightall, ScreenWidth, 1)];
    line3.backgroundColor = [UIColor colorWithHexString:@"#f2f2f2"];
    [scrollView_content addSubview:line3];
    heightall = heightall + 1;
    //提货地址图片加地址
    
    UIImageView *tihuo_img = [[UIImageView alloc]init];
    tihuo_img.frame = CGRectMake(0, heightall, 40, 40);
    tihuo_img.image = [UIImage imageNamed:@"order_detail_tihuo_address_image"];
    tihuo_img.contentMode = UIViewContentModeCenter;
    [scrollView_content addSubview:tihuo_img];
    
    NSString *tihuoAddress = [NSString stringWithFormat:@"%@",dic[@"pickupAddress"]];
    UILabel *tihuoAddress_lab = [[UILabel alloc]init];
    tihuoAddress_lab.frame = CGRectMake(43, heightall + 5 , ScreenWidth - 55, 46);
    tihuoAddress_lab.text = tihuoAddress;
    tihuoAddress_lab.font = [UIFont systemFontOfSize:textSize];
    tihuoAddress_lab.baselineAdjustment = UIBaselineAdjustmentAlignCenters;
    tihuoAddress_lab.lineBreakMode = NSLineBreakByWordWrapping;
    tihuoAddress_lab.numberOfLines = 0;
    //设置行间距
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:tihuoAddress];
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    [paragraphStyle setLineSpacing:3];
    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [tihuoAddress length])];
    tihuoAddress_lab.attributedText = attributedString;
    
    [scrollView_content addSubview:tihuoAddress_lab];
    [tihuoAddress_lab sizeToFit];
    //横线
    heightall = heightall + 46;
    UIView *line4 = [[UIView alloc]initWithFrame:CGRectMake(0, heightall, ScreenWidth, 1)];
    line4.backgroundColor = [UIColor colorWithHexString:@"#f2f2f2"];
    [scrollView_content addSubview:line4];
    heightall = heightall + 1;
    //提货时间
    //中间竖线
    UIView *shuline1 = [[UIView alloc]initWithFrame:CGRectMake(ScreenWidth / 2, heightall, 1, 40)];
    shuline1.backgroundColor = [UIColor colorWithHexString:@"#f2f2f2"];
    [scrollView_content addSubview:shuline1];
    //应提货时间
    UIImageView *time_img1 = [[UIImageView alloc]init];
    time_img1.frame = CGRectMake(0, heightall, 40, 40);
    time_img1.image = [UIImage imageNamed:@"order_detail_time_image"];
    time_img1.contentMode = UIViewContentModeCenter;
    [scrollView_content addSubview:time_img1];
    
    NSString *tihuoTime1 = [NSString stringWithFormat:@"%@",dic[@"serviceDate"]];
    UILabel *tihuoTime1_lab = [[UILabel alloc]init];
    tihuoTime1_lab.frame = CGRectMake(43, heightall , (ScreenWidth - 1) / 2 - 43, 40);
    tihuoTime1_lab.text = tihuoTime1;
    tihuoTime1_lab.font = [UIFont systemFontOfSize:textSize];
    tihuoTime1_lab.lineBreakMode = NSLineBreakByWordWrapping;
    tihuoTime1_lab.numberOfLines = 0;
    [scrollView_content addSubview:tihuoTime1_lab];
    //提货时间
    UIImageView *time_img2 = [[UIImageView alloc]init];
    time_img2.frame = CGRectMake((ScreenWidth - 1) / 2, heightall, 40, 40);
    time_img2.image = [UIImage imageNamed:@"order_detail_time_image"];
    time_img2.contentMode = UIViewContentModeCenter;
    [scrollView_content addSubview:time_img2];
    
    NSString *tihuoTime2 = [NSString stringWithFormat:@"%@",dic[@"pickupTime"]];
    UILabel *tihuoTime2_lab = [[UILabel alloc]init];
    tihuoTime2_lab.frame = CGRectMake((ScreenWidth - 1) / 2 + 43, heightall , (ScreenWidth - 1) / 2 - 43, 40);
    tihuoTime2_lab.text = tihuoTime2;
    tihuoTime2_lab.font = [UIFont systemFontOfSize:textSize];
    tihuoTime2_lab.lineBreakMode = NSLineBreakByWordWrapping;
    tihuoTime2_lab.numberOfLines = 0;
    [scrollView_content addSubview:tihuoTime2_lab];
    //横线
    heightall = heightall + 40;
    UIView *line5 = [[UIView alloc]initWithFrame:CGRectMake(0, heightall, ScreenWidth, 1)];
    line5.backgroundColor = [UIColor colorWithHexString:@"#f2f2f2"];
    [scrollView_content addSubview:line5];
    heightall = heightall + 1;
    //产品信息
    
    NSArray *products = dic[@"products"];
    for (int i = 0 ; i < products.count; i++) {
        
        NSDictionary *data = products[i];
        //图片
        UIImageView *p_img = [[UIImageView alloc]init];
        p_img.frame = CGRectMake(0, heightall, 40, 40);
        p_img.image = [UIImage imageNamed:@"order_detail_project_image"];
        p_img.contentMode = UIViewContentModeCenter;
        [scrollView_content addSubview:p_img];
        //产品名称
        NSString *p1_str = [NSString stringWithFormat:@"%@(%@)",data[@"productName"],data[@"productCode"]];
        UILabel *p_lab1 = [[UILabel alloc]init];
        widget = [p1_str sizeWithFont:[UIFont systemFontOfSize:textSize]].width;
        p_lab1.frame = CGRectMake(43, heightall , widget, 40);
        p_lab1.text = p1_str;
        p_lab1.font = [UIFont systemFontOfSize:textSize];
        [scrollView_content addSubview:p_lab1];
        //产品数量
        NSString *p2_str = data[@"productCount"];
        UILabel *p_lab2 = [[UILabel alloc]init];
        widget = [p2_str sizeWithFont:[UIFont systemFontOfSize:textSize]].width;
        p_lab2.frame = CGRectMake(ScreenWidth - widget - 6, heightall ,widget, 40);
        p_lab2.text = p2_str;
        p_lab2.font = [UIFont systemFontOfSize:textSize];
        [scrollView_content addSubview:p_lab2];
        heightall = heightall + 40;
        //横线
        UIView *pline = [[UIView alloc]initWithFrame:CGRectMake(0, heightall, ScreenWidth, 1)];
        pline.backgroundColor = [UIColor colorWithHexString:@"#f2f2f2"];
        [scrollView_content addSubview:pline];
        heightall = heightall + 1;

    }
    //提货电话
    
    //左面电话

    UIButton *left_c = [[UIButton alloc]initWithFrame:CGRectMake(0, heightall, (ScreenWidth - 1) / 2, 50)];
    left_c.tag = 21;
    [left_c setBackgroundImage:[self createImageWithColor:[UIColor whiteColor]] forState:UIControlStateNormal];
    [left_c setBackgroundImage:[self createImageWithColor:[UIColor orangeColor]] forState:UIControlStateSelected];
    [left_c addTarget:self action:@selector(button_click:) forControlEvents:UIControlEventTouchUpInside];
    
    [scrollView_content addSubview:left_c];
    

    //图片
    UIImageView *left_img = [[UIImageView alloc]init];
    left_img.frame = CGRectMake(0, heightall, 40, 50);
    left_img.image = [UIImage imageNamed:@"order_deatail_phone_image"];
    left_img.contentMode = UIViewContentModeCenter;
    [scrollView_content addSubview:left_img];
    //左面电话
    NSString *tihuo_left_str = [NSString stringWithFormat:@"%@(%@)",dic[@"pickupName"],dic[@"pickupPhone"]];
    UILabel *leftBtn = [[UILabel alloc]init];

    leftBtn.frame = CGRectMake(43, heightall, (ScreenWidth - 1) / 2 - 43, 50);
    leftBtn.text = tihuo_left_str;
    leftBtn.font = [UIFont systemFontOfSize:textSize];
    [scrollView_content addSubview:leftBtn];
    
    //右面电话
    UIButton *right_c = [[UIButton alloc]initWithFrame:CGRectMake((ScreenWidth - 1) / 2, heightall, (ScreenWidth - 1) / 2, 50)];
    right_c.tag = 22;
    [right_c setBackgroundImage:[self createImageWithColor:[UIColor whiteColor]] forState:UIControlStateNormal];
    [right_c setBackgroundImage:[self createImageWithColor:[UIColor orangeColor]] forState:UIControlStateSelected];
    [right_c addTarget:self action:@selector(button_click:) forControlEvents:UIControlEventTouchUpInside];
    
    [scrollView_content addSubview:right_c];
//    //图片
//    UIImageView *right_img = [[UIImageView alloc]init];
//    right_img.frame = CGRectMake((ScreenWidth - 1) / 2, heightall, 40, 50);
//    right_img.image = [UIImage imageNamed:@"order_deatail_phone_image"];
//    right_img.contentMode = UIViewContentModeCenter;
//    [scrollView_content addSubview:right_img];
//    //右面电话
//    NSString *tihuo_right_str = @"张三(15863090067)";
//    UILabel *rightBtn = [[UILabel alloc]init];
//    
//    rightBtn.frame = CGRectMake((ScreenWidth - 1) / 2 + 43, heightall, (ScreenWidth - 1) / 2 - 43, 50);
//    rightBtn.text = tihuo_right_str;
//    rightBtn.font = [UIFont systemFontOfSize:textSize];
//    [scrollView_content addSubview:rightBtn];
    //中间竖线
    UIView *shuline2 = [[UIView alloc]initWithFrame:CGRectMake(ScreenWidth / 2, heightall, 1, 50)];
    shuline2.backgroundColor = [UIColor colorWithHexString:@"#f2f2f2"];
    [scrollView_content addSubview:shuline2];
    
    //横线
    heightall = heightall + 50;
    UIView *line6 = [[UIView alloc]initWithFrame:CGRectMake(0, heightall, ScreenWidth, 1)];
    line6.backgroundColor = [UIColor colorWithHexString:@"#f2f2f2"];
    [scrollView_content addSubview:line6];
    heightall = heightall + 1;
    
    //客户信息标题
    NSString *kehuTitle = @"客户信息";
    UILabel *kehuTitle_lab = [[UILabel alloc]init];
    widget = [kehuTitle sizeWithFont:[UIFont systemFontOfSize:textSize]].width;
    kehuTitle_lab.frame = CGRectMake(6, heightall , widget, 40);
    kehuTitle_lab.text = kehuTitle;
    kehuTitle_lab.font = [UIFont systemFontOfSize:textSize];
    [scrollView_content addSubview:kehuTitle_lab];
    heightall = heightall + 40;
    UIView *line7 = [[UIView alloc]initWithFrame:CGRectMake(0, heightall, ScreenWidth, 1)];
    line7.backgroundColor = [UIColor colorWithHexString:@"#f2f2f2"];
    [scrollView_content addSubview:line7];
    heightall = heightall + 1;
    //客户地址图片加地址
    
    UIImageView *kehu_img = [[UIImageView alloc]init];
    kehu_img.frame = CGRectMake(0, heightall, 40, 40);
    kehu_img.image = [UIImage imageNamed:@"order_detail_tihuo_address_image"];
    kehu_img.contentMode = UIViewContentModeCenter;
    [scrollView_content addSubview:kehu_img];
    
    NSString *kehuAddress = [NSString stringWithFormat:@"%@",dic[@"userAddress"]];
    UILabel *kehuAddress_lab = [[UILabel alloc]init];
    kehuAddress_lab.frame = CGRectMake(43, heightall + 5 , ScreenWidth - 55, 46);
    kehuAddress_lab.text = kehuAddress;
    kehuAddress_lab.font = [UIFont systemFontOfSize:textSize];
    kehuAddress_lab.baselineAdjustment = UIBaselineAdjustmentAlignCenters;
    kehuAddress_lab.lineBreakMode = NSLineBreakByWordWrapping;
    kehuAddress_lab.numberOfLines = 2;
    //设置行间距
    NSMutableAttributedString *attributedString2 = [[NSMutableAttributedString alloc] initWithString:kehuAddress];
    NSMutableParagraphStyle *paragraphStyle2 = [[NSMutableParagraphStyle alloc] init];
    [paragraphStyle2 setLineSpacing:3];
    [attributedString2 addAttribute:NSParagraphStyleAttributeName value:paragraphStyle2 range:NSMakeRange(0, [kehuAddress length])];
    kehuAddress_lab.attributedText = attributedString2;
    
    [scrollView_content addSubview:kehuAddress_lab];
    [kehuAddress_lab sizeToFit];
    //横线
    heightall = heightall + 46;
    UIView *line8 = [[UIView alloc]initWithFrame:CGRectMake(0, heightall, ScreenWidth, 1)];
    line8.backgroundColor = [UIColor colorWithHexString:@"#f2f2f2"];
    [scrollView_content addSubview:line8];
    heightall = heightall + 1;
    
    //上门时间
    //中间竖线
    UIView *shuline3 = [[UIView alloc]initWithFrame:CGRectMake(ScreenWidth / 2, heightall, 1, 40)];
    shuline3.backgroundColor = [UIColor colorWithHexString:@"#f2f2f2"];
    [scrollView_content addSubview:shuline3];
    //预约时间
    UIImageView *time_img3 = [[UIImageView alloc]init];
    time_img3.frame = CGRectMake(0, heightall, 40, 40);
    time_img3.image = [UIImage imageNamed:@"order_detail_time_image"];
    time_img3.contentMode = UIViewContentModeCenter;
    [scrollView_content addSubview:time_img3];
    
    NSString *kehuTime1 = [NSString stringWithFormat:@"%@",dic[@"appointmentTime"]];
    UILabel *kehuTime1_lab = [[UILabel alloc]init];
    kehuTime1_lab.frame = CGRectMake(43, heightall , (ScreenWidth - 1) / 2 - 43, 40);
    kehuTime1_lab.text = kehuTime1;
    kehuTime1_lab.font = [UIFont systemFontOfSize:textSize];
    kehuTime1_lab.lineBreakMode = NSLineBreakByWordWrapping;
    kehuTime1_lab.numberOfLines = 0;
    [scrollView_content addSubview:kehuTime1_lab];
    //上门时间
    UIImageView *time_img4 = [[UIImageView alloc]init];
    time_img4.frame = CGRectMake((ScreenWidth - 1) / 2, heightall, 40, 40);
    time_img4.image = [UIImage imageNamed:@"order_detail_time_image"];
    time_img4.contentMode = UIViewContentModeCenter;
    [scrollView_content addSubview:time_img4];
    
    NSString *kehuTime2 = [NSString stringWithFormat:@"%@",dic[@"serviceTime"]];
    UILabel *kehuTime2_lab = [[UILabel alloc]init];
    kehuTime2_lab.frame = CGRectMake((ScreenWidth - 1) / 2 + 43, heightall , (ScreenWidth - 1) / 2 - 43, 40);
    kehuTime2_lab.text = kehuTime2;
    kehuTime2_lab.font = [UIFont systemFontOfSize:textSize];
    kehuTime2_lab.lineBreakMode = NSLineBreakByWordWrapping;
    kehuTime2_lab.numberOfLines = 0;
    [scrollView_content addSubview:kehuTime2_lab];
    //横线
    heightall = heightall + 40;
    UIView *line9 = [[UIView alloc]initWithFrame:CGRectMake(0, heightall, ScreenWidth, 1)];
    line9.backgroundColor = [UIColor colorWithHexString:@"#f2f2f2"];
    [scrollView_content addSubview:line9];
    heightall = heightall + 1;
    //客户电话
    
    //左面电话
    
    UIButton *left_c2 = [[UIButton alloc]initWithFrame:CGRectMake(0, heightall, (ScreenWidth - 1) / 2, 50)];
    left_c2.tag = 23;
    [left_c2 setBackgroundImage:[self createImageWithColor:[UIColor whiteColor]] forState:UIControlStateNormal];
    [left_c2 setBackgroundImage:[self createImageWithColor:[UIColor orangeColor]] forState:UIControlStateSelected];
    [left_c2 addTarget:self action:@selector(button_click:) forControlEvents:UIControlEventTouchUpInside];
    
    [scrollView_content addSubview:left_c2];
    //图片
    UIImageView *left_img2 = [[UIImageView alloc]init];
    left_img2.frame = CGRectMake(0, heightall, 40, 50);
    left_img2.image = [UIImage imageNamed:@"order_deatail_phone_image"];
    left_img2.contentMode = UIViewContentModeCenter;
    [scrollView_content addSubview:left_img2];
    //左面电话
    NSString *kehu_left_str = [NSString stringWithFormat:@"%@(%@)",dic[@"userName"],dic[@"userPhone"]];
    UILabel *leftBtn2 = [[UILabel alloc]init];
    
    leftBtn2.frame = CGRectMake(43, heightall, (ScreenWidth - 1) / 2 - 43, 50);
    leftBtn2.text = kehu_left_str;
    leftBtn2.font = [UIFont systemFontOfSize:textSize];
    [scrollView_content addSubview:leftBtn2];
    
    //右面电话
    UIButton *right_c2 = [[UIButton alloc]initWithFrame:CGRectMake((ScreenWidth - 1) / 2, heightall, (ScreenWidth - 1) / 2, 50)];
    right_c2.tag = 24;
    [right_c2 setBackgroundImage:[self createImageWithColor:[UIColor whiteColor]] forState:UIControlStateNormal];
    [right_c2 setBackgroundImage:[self createImageWithColor:[UIColor orangeColor]] forState:UIControlStateSelected];
    [right_c2 addTarget:self action:@selector(button_click:) forControlEvents:UIControlEventTouchUpInside];
    
    [scrollView_content addSubview:right_c2];
    //图片
    UIImageView *right_img2 = [[UIImageView alloc]init];
    right_img2.frame = CGRectMake((ScreenWidth - 1) / 2, heightall, 40, 50);
    right_img2.image = [UIImage imageNamed:@"order_deatail_phone_image"];
    right_img2.contentMode = UIViewContentModeCenter;
    [scrollView_content addSubview:right_img2];
    //右面电话
    NSString *kehu_right_str = [NSString stringWithFormat:@"%@(%@)",dic[@"userName"],dic[@"userPhone2"]];
    UILabel *rightBtn2 = [[UILabel alloc]init];
    
    rightBtn2.frame = CGRectMake((ScreenWidth - 1) / 2 + 43, heightall, (ScreenWidth - 1) / 2 - 43, 50);
    rightBtn2.text = kehu_right_str;
    rightBtn2.font = [UIFont systemFontOfSize:textSize];
    [scrollView_content addSubview:rightBtn2];
    //中间竖线
    UIView *shuline4 = [[UIView alloc]initWithFrame:CGRectMake(ScreenWidth / 2, heightall, 1, 50)];
    shuline4.backgroundColor = [UIColor colorWithHexString:@"#f2f2f2"];
    [scrollView_content addSubview:shuline4];
    
    //横线
    heightall = heightall + 50;
    UIView *line10 = [[UIView alloc]initWithFrame:CGRectMake(0, heightall, ScreenWidth, 3)];
    line10.backgroundColor = [UIColor colorWithHexString:@"#f2f2f2"];
    [scrollView_content addSubview:line10];
    heightall = heightall + 3;
    
    scrollView_content.frame = CGRectMake(0, 0, ScreenWidth, heightall);
    
    [self.scrollView addSubview:scrollView_content];
    //self.scrollView.showsVerticalScrollIndicator = NO;
    self.scrollView.contentSize = scrollView_content.frame.size;
    
    return heightall;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

- (void)setTheBottomView:(NSDictionary *) dic{
    
    for (UIView *view in self.buttom_view.subviews) {
        [view removeFromSuperview];
    }
    //问题件
    
    UIButton *probleBtn = [[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth - 60, 0 , 60, 60)];
    probleBtn.tag = 1;
    [probleBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [probleBtn setTitle:@"问题" forState:UIControlStateNormal];
    [probleBtn setBackgroundColor:[UIColor colorWithHexString:@"#ff7e00"]];
     probleBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [probleBtn addTarget:self action:@selector(showOppView:) forControlEvents:UIControlEventTouchUpInside];
    [self.buttom_view addSubview:probleBtn];
    
    //改约
    UIButton *changeBtn = [[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth - 121, 0 , 60, 60)];
    changeBtn.tag = 3;
    [changeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [changeBtn setTitle:@"改约" forState:UIControlStateNormal];
    [changeBtn setBackgroundColor:[UIColor colorWithHexString:@"#ff7e00"]];
    changeBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [changeBtn addTarget:self action:@selector(showOppView:) forControlEvents:UIControlEventTouchUpInside];

    [self.buttom_view addSubview:changeBtn];
    
    //签收
    UIButton *signBtn = [[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth - 182, 0 , 60, 60)];
    
    [signBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    if ([dic[@"serviceStatus"] isEqualToString:@"待签收"]) {
        [signBtn setTitle:@"签收" forState:UIControlStateNormal];
        signBtn.tag = 2;

    }else if([dic[@"serviceStatus"] isEqualToString:@"待提货"]){
        [signBtn setTitle:@"提货" forState:UIControlStateNormal];
        signBtn.tag = 4;

    }
        [signBtn setBackgroundColor:[UIColor colorWithHexString:@"#ff7e00"]];
    [signBtn addTarget:self action:@selector(showOppView:) forControlEvents:UIControlEventTouchUpInside];
    signBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [self.buttom_view addSubview:signBtn];
    
    //电话content
    UIButton *phoneBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0 , ScreenWidth - 182, 60)];
    phoneBtn.tag = 25;
    [phoneBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    [phoneBtn setBackgroundColor:[UIColor colorWithHexString:@"#333333"]];

    [phoneBtn addTarget:self action:@selector(button_click:) forControlEvents:UIControlEventTouchUpInside];
    [self.buttom_view addSubview:phoneBtn];
    //电话
    UILabel *userLab = [[UILabel alloc]init];
    userLab.text = [NSString stringWithFormat:@"%@(客户)",dic[@"userName"]];
     float widget = [userLab.text sizeWithFont:[UIFont systemFontOfSize:13]].width;
    userLab.frame = CGRectMake(8, 0 , widget, 29);
    userLab.textColor = [UIColor whiteColor];
    userLab.font = [UIFont systemFontOfSize:13];
    [self.buttom_view addSubview:userLab];
    //电话
    UILabel *phoneLab = [[UILabel alloc]init];
    if (dic[@"userPhone"] == nil) {
        phoneLab.text = [NSString stringWithFormat:@"%@",dic[@"userPhone2"]];
    }else{
        phoneLab.text = [NSString stringWithFormat:@"%@",dic[@"userPhone"]];
    }
    
    widget = [phoneLab.text sizeWithFont:[UIFont systemFontOfSize:13]].width;
    phoneLab.font = [UIFont systemFontOfSize:13];
    phoneLab.frame = CGRectMake(8, 30 , widget, 30);
    phoneLab.textColor = [UIColor whiteColor];
    [self.buttom_view addSubview:phoneLab];
    
    
    UIImageView *phoneImage = [[UIImageView alloc]initWithFrame:CGRectMake(phoneBtn.frame.size.width - 70, 0, 60, 60)];
    phoneImage.image = [UIImage imageNamed:@"phone_icon"];
    phoneImage.contentMode = UIViewContentModeCenter;
    [self.buttom_view addSubview:phoneImage];

    
}
-(void)setTheNodeView:(int) heightAll{
    //节点信息
    UIView *childView = [self.scrollView viewWithTag:10102];
    if (childView != nil) {
        [childView removeFromSuperview];
    }
    float textSize = 13;
    int heightall = 0;
    
    UIView *nodeView = [[UIView alloc] init];
    nodeView.tag = 10102;
    //标题
    NSString *nodeTitle = @"节点信息";
    UILabel *nodeTitle_lab = [[UILabel alloc]init];
    int widget = [nodeTitle sizeWithFont:[UIFont systemFontOfSize:textSize]].width;
    nodeTitle_lab.frame = CGRectMake(6, heightall , widget, 40);
    nodeTitle_lab.text = nodeTitle;
    nodeTitle_lab.font = [UIFont systemFontOfSize:textSize];
    [nodeView addSubview:nodeTitle_lab];
    
    heightall = heightall + 40;
    UIView *line1 = [[UIView alloc]initWithFrame:CGRectMake(0, heightall, ScreenWidth, 1)];
    line1.backgroundColor = [UIColor colorWithHexString:@"#f2f2f2"];
    [nodeView addSubview:line1];
    heightall = heightall + 1;
    

    for (int i = 0 ; i < _nodeData.count; i++) {
        
        NSDictionary *dic = _nodeData[i];
        
        UILabel *lab1 = [[UILabel alloc]initWithFrame:CGRectMake(41, heightall, ScreenWidth - 60, 30)];
        lab1.font = [UIFont systemFontOfSize:13];
        lab1.text = dic[@"statusName"];
        [nodeView addSubview:lab1];
        
        heightall = heightall + 30;
        
        UIImageView *time_img = [[UIImageView alloc]initWithFrame:CGRectMake(41, heightall, 20, 30)];
        time_img.contentMode = UIViewContentModeCenter;
        time_img.image = [UIImage imageNamed:@"order_detail_time_image"];
        [nodeView addSubview:time_img];
        
        UILabel *lab2 = [[UILabel alloc]initWithFrame:CGRectMake(61, heightall, ScreenWidth - 60, 30)];
        lab2.font = [UIFont systemFontOfSize:11];
        lab2.text = dic[@"operatingDate"];
        [nodeView addSubview:lab2];
        
        heightall = heightall + 30;
        
        NSArray *photos = dic[@"nodeImg"];
        if (photos.count > 0) {
            int widget =  (ScreenWidth - 101) / 3;
            for (int j = 0 ; j < photos.count; j++) {
                UIImage_WebCache *image = [[UIImage_WebCache alloc]initWithFrame:CGRectMake(41 + j * widget + j * 20, heightall + 10, widget, widget)];
                image.image = [UIImage imageNamed:@"default_image"];
                [image loadImage:[NSURL URLWithString:photos[j]]];
                
                UIControl *controls = [[UIControl alloc]initWithFrame:CGRectMake(41 + j * widget + j * 20, heightall + 10, widget, widget)];
                image.tag = 100000 + j;
                [controls addTarget:self action:@selector(magnifyImage:) forControlEvents:UIControlEventTouchUpInside];
                [nodeView addSubview:controls];
                [nodeView addSubview:image];
            }
            heightall = heightall + widget;
            heightall = heightall + 10;
            
            UIView *line1 = [[UIView alloc]initWithFrame:CGRectMake(20, lab1.frame.origin.y, 1, 81 + widget)];
            line1.backgroundColor = [UIColor colorWithHexString:@"#f2f2f2"];
            [nodeView addSubview:line1];
            
        }else{
            UIView *line1 = [[UIView alloc]initWithFrame:CGRectMake(20, lab1.frame.origin.y, 1, 71)];
            line1.backgroundColor = [UIColor colorWithHexString:@"#f2f2f2"];
            [nodeView addSubview:line1];
        }
        heightall = heightall + 10;
        UIView *line = [[UIView alloc]initWithFrame:CGRectMake(0, heightall, ScreenWidth, 1)];
        line.backgroundColor = [UIColor colorWithHexString:@"#f2f2f2"];
        [nodeView addSubview:line];
        

        heightall = heightall + 1;

        
    }
    
    nodeView.frame = CGRectMake(0, heightAll, ScreenWidth, heightall);
    
    [self.scrollView addSubview:nodeView];
    //self.scrollView.showsVerticalScrollIndicator = NO;
    self.scrollView.contentSize = CGSizeMake(ScreenWidth, heightAll + heightall);

    
}
- (void)magnifyImage:(UIView *)imageview
{
    NSLog(@"局部放大");
    UIImageView *img = [self.view viewWithTag:100000 - imageview.tag ];
    [SJAvatarBrowser showImage:img];//调用方法
}
- (void)setTheBottomView2:(NSDictionary *) dic{
    
    
    for (UIView *view in self.buttom_view.subviews) {
        [view removeFromSuperview];
    }
    //问题件
    
    UIButton *probleBtn = [[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth - 60, 0 , 60, 60)];
    probleBtn.tag = 1;
    [probleBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [probleBtn setTitle:@"问题" forState:UIControlStateNormal];
    [probleBtn setBackgroundColor:[UIColor colorWithHexString:@"#ff7e00"]];
    probleBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [probleBtn addTarget:self action:@selector(showOppView:) forControlEvents:UIControlEventTouchUpInside];
    [self.buttom_view addSubview:probleBtn];
    
    //预约
    UIButton *changeBtn = [[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth - 121, 0 , 60, 60)];
    changeBtn.tag = 5;
    [changeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [changeBtn setTitle:@"预约" forState:UIControlStateNormal];
    [changeBtn setBackgroundColor:[UIColor colorWithHexString:@"#ff7e00"]];
    changeBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [changeBtn addTarget:self action:@selector(showOppView:) forControlEvents:UIControlEventTouchUpInside];
    
    [self.buttom_view addSubview:changeBtn];
    
    
    
    //电话content
    UIButton *phoneBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0 , ScreenWidth - 121, 60)];
    phoneBtn.tag = 25;
    [phoneBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    [phoneBtn setBackgroundColor:[UIColor colorWithHexString:@"#333333"]];
    
    [phoneBtn addTarget:self action:@selector(button_click:) forControlEvents:UIControlEventTouchUpInside];
    [self.buttom_view addSubview:phoneBtn];
    //电话
    UILabel *userLab = [[UILabel alloc]init];
    userLab.text = [NSString stringWithFormat:@"%@(客户)",dic[@"userName"]];
    float widget = [userLab.text sizeWithFont:[UIFont systemFontOfSize:13]].width;
    userLab.frame = CGRectMake(8, 0 , widget, 29);
    userLab.textColor = [UIColor whiteColor];
    userLab.font = [UIFont systemFontOfSize:13];
    [self.buttom_view addSubview:userLab];
    //电话
    UILabel *phoneLab = [[UILabel alloc]init];
    if (dic[@"userPhone"] == nil) {
        phoneLab.text = [NSString stringWithFormat:@"%@",dic[@"userPhone2"]];
    }else{
        phoneLab.text = [NSString stringWithFormat:@"%@",dic[@"userPhone"]];
    }
    widget = [phoneLab.text sizeWithFont:[UIFont systemFontOfSize:13]].width;
    phoneLab.font = [UIFont systemFontOfSize:13];
    phoneLab.frame = CGRectMake(8, 30 , widget, 30);
    phoneLab.textColor = [UIColor whiteColor];
    [self.buttom_view addSubview:phoneLab];
    
    UIImageView *phoneImage = [[UIImageView alloc]initWithFrame:CGRectMake(phoneBtn.frame.size.width - 70, 0, 60, 60)];
    phoneImage.image = [UIImage imageNamed:@"phone_icon"];
    phoneImage.contentMode = UIViewContentModeCenter;
    [self.buttom_view addSubview:phoneImage];
}
- (void)setTheBottomView3:(NSDictionary *) dic{
    
    
    for (UIView *view in self.buttom_view.subviews) {
        [view removeFromSuperview];
    }
    
    
    
    
    //电话content
    UIButton *phoneBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0 , ScreenWidth , 60)];
    phoneBtn.tag = 25;
    [phoneBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    [phoneBtn setBackgroundColor:[UIColor colorWithHexString:@"#333333"]];
    
    [phoneBtn addTarget:self action:@selector(button_click:) forControlEvents:UIControlEventTouchUpInside];
    [self.buttom_view addSubview:phoneBtn];
    //电话
    UILabel *userLab = [[UILabel alloc]init];
    userLab.text = [NSString stringWithFormat:@"%@",dic[@"userName"]];
    float widget = [userLab.text sizeWithFont:[UIFont systemFontOfSize:13]].width;
    userLab.frame = CGRectMake(8, 0 , widget, 29);
    userLab.textColor = [UIColor whiteColor];
    userLab.font = [UIFont systemFontOfSize:13];
    [self.buttom_view addSubview:userLab];
    //电话
    UILabel *phoneLab = [[UILabel alloc]init];
    if (dic[@"userPhone"] == nil) {
        phoneLab.text = [NSString stringWithFormat:@"%@",dic[@"userPhone2"]];
    }else{
        phoneLab.text = [NSString stringWithFormat:@"%@",dic[@"userPhone"]];
    }
    widget = [phoneLab.text sizeWithFont:[UIFont systemFontOfSize:13]].width;
    phoneLab.font = [UIFont systemFontOfSize:13];
    phoneLab.frame = CGRectMake(8, 30 , widget, 30);
    phoneLab.textColor = [UIColor whiteColor];
    [self.buttom_view addSubview:phoneLab];
    
    
    UIImageView *phoneImage = [[UIImageView alloc]initWithFrame:CGRectMake(phoneBtn.frame.size.width - 70, 0, 60, 60)];
    phoneImage.image = [UIImage imageNamed:@"phone_icon"];
    phoneImage.contentMode = UIViewContentModeCenter;
    [self.buttom_view addSubview:phoneImage];

    
}

- (void)setTheBottomView4:(NSDictionary *) dic{
    //抢单
    
    for (UIView *view in self.buttom_view.subviews) {
        [view removeFromSuperview];
    }
    
    
    //抢单
    
    UIButton *grabBtn = [[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth / 2 , 0 , ScreenWidth / 2, 60)];
    grabBtn.tag = 77;
    [grabBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [grabBtn setTitle:@"抢单" forState:UIControlStateNormal];
    [grabBtn setBackgroundColor:[UIColor colorWithHexString:@"#ff7e00"]];
    grabBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [grabBtn addTarget:self action:@selector(showOppView:) forControlEvents:UIControlEventTouchUpInside];
    [self.buttom_view addSubview:grabBtn];
    
    //电话content
    UIButton *phoneBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0 , ScreenWidth / 2 , 60)];
    phoneBtn.tag = 25;
    [phoneBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    [phoneBtn setBackgroundColor:[UIColor colorWithHexString:@"#333333"]];
    
    [phoneBtn addTarget:self action:@selector(button_click:) forControlEvents:UIControlEventTouchUpInside];
    [self.buttom_view addSubview:phoneBtn];
    //电话
    UILabel *userLab = [[UILabel alloc]init];
    userLab.text = [NSString stringWithFormat:@"%@(客户)",dic[@"userName"]];
    float widget = [userLab.text sizeWithFont:[UIFont systemFontOfSize:13]].width;
    userLab.frame = CGRectMake(8, 0 , widget, 29);
    userLab.textColor = [UIColor whiteColor];
    userLab.font = [UIFont systemFontOfSize:13];
    [self.buttom_view addSubview:userLab];
    //电话
    UILabel *phoneLab = [[UILabel alloc]init];
    if (dic[@"userPhone"] == nil) {
        phoneLab.text = [NSString stringWithFormat:@"%@",dic[@"userPhone2"]];
    }else{
        phoneLab.text = [NSString stringWithFormat:@"%@",dic[@"userPhone"]];
    }
    widget = [phoneLab.text sizeWithFont:[UIFont systemFontOfSize:13]].width;
    phoneLab.font = [UIFont systemFontOfSize:13];
    phoneLab.frame = CGRectMake(8, 30 , widget, 30);
    phoneLab.textColor = [UIColor whiteColor];
    [self.buttom_view addSubview:phoneLab];
    
    
    UIImageView *phoneImage = [[UIImageView alloc]initWithFrame:CGRectMake(phoneBtn.frame.size.width - 70, 0, 60, 60)];
    phoneImage.image = [UIImage imageNamed:@"phone_icon"];
    phoneImage.contentMode = UIViewContentModeCenter;
    [self.buttom_view addSubview:phoneImage];

}
- (void)setTheBottomView5:(NSDictionary *) dic{
    //核销
    
    for (UIView *view in self.buttom_view.subviews) {
        [view removeFromSuperview];
    }
    
    
    //核销
    
    UIButton *hxBtn = [[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth / 2 , 0 ,ScreenWidth / 2, 60)];
    hxBtn.tag = 88;
    [hxBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [hxBtn setTitle:@"核销" forState:UIControlStateNormal];
    [hxBtn setBackgroundColor:[UIColor colorWithHexString:@"#ff7e00"]];
    hxBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [hxBtn addTarget:self action:@selector(showOppView:) forControlEvents:UIControlEventTouchUpInside];
    [self.buttom_view addSubview:hxBtn];
    
    //电话content
    UIButton *phoneBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0 , ScreenWidth / 2 , 60)];
    phoneBtn.tag = 25;
    [phoneBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    [phoneBtn setBackgroundColor:[UIColor colorWithHexString:@"#333333"]];
    
    [phoneBtn addTarget:self action:@selector(button_click:) forControlEvents:UIControlEventTouchUpInside];
    [self.buttom_view addSubview:phoneBtn];
    //电话
    UILabel *userLab = [[UILabel alloc]init];
    userLab.text = [NSString stringWithFormat:@"%@(客户)",dic[@"userName"]];
    float widget = [userLab.text sizeWithFont:[UIFont systemFontOfSize:13]].width;
    userLab.frame = CGRectMake(8, 0 , widget, 29);
    userLab.textColor = [UIColor whiteColor];
    userLab.font = [UIFont systemFontOfSize:13];
    [self.buttom_view addSubview:userLab];
    //电话
    UILabel *phoneLab = [[UILabel alloc]init];
    if (dic[@"userPhone"] == nil) {
        phoneLab.text = [NSString stringWithFormat:@"%@",dic[@"userPhone2"]];
    }else{
        phoneLab.text = [NSString stringWithFormat:@"%@",dic[@"userPhone"]];
    }
    widget = [phoneLab.text sizeWithFont:[UIFont systemFontOfSize:13]].width;
    phoneLab.font = [UIFont systemFontOfSize:13];
    phoneLab.frame = CGRectMake(8, 30 , widget, 30);
    phoneLab.textColor = [UIColor whiteColor];
    [self.buttom_view addSubview:phoneLab];
    
    
    UIImageView *phoneImage = [[UIImageView alloc]initWithFrame:CGRectMake(phoneBtn.frame.size.width - 70, 0, 60, 60)];
    phoneImage.image = [UIImage imageNamed:@"phone_icon"];
    phoneImage.contentMode = UIViewContentModeCenter;
    [self.buttom_view addSubview:phoneImage];
    
}

-(void)viewWillAppear:(BOOL)animated{
    NSLog(@"viewWillAppear");
    self.navigationController.navigationBarHidden = YES;
    [self getData];
    
}
-(void)viewDidAppear:(BOOL)animated{
    
}


- (IBAction)button_click:(id)sender {
    NSLog(@"电话被电击了");
    UIView * view = sender;
    if(view.tag == 11){
        //返回键
        [self.navigationController popViewControllerAnimated:YES];
    }else{
        NSString *tel = @"";
        switch (view.tag) {
            case 21:
                tel = _orderd[@"pickupPhone"];
                break;
            case 22:
                 tel = _orderd[@"pickupPhone2"];
                break;
            case 23:
                 tel = _orderd[@"userPhone"];
                break;
            case 24:
                 tel = _orderd[@"userPhone2"];
                break;
            case 25:
                 tel = _orderd[@"userPhone"];
                break;
                
            default:
                break;
        }
        UIWebView*callWebview =[[UIWebView alloc] init];
        NSURL *telURL =[NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",tel]];// 貌似tel:// 或者 tel: 都行
        [callWebview loadRequest:[NSURLRequest requestWithURL:telURL]];
        //记得添加到view上
        [self.view addSubview:callWebview];
    }
}

-(void)showOppView:(UIView *) button{
    UIStoryboard *story = [UIStoryboard storyboardWithName:@"App_Main" bundle:[NSBundle mainBundle]];
    if(button.tag == 1){
        
        ProblemViewController *orderProblem = [story instantiateViewControllerWithIdentifier:@"problem_opp"];
        orderProblem.serviceNo = _orderd[@"serviceNo"];
        orderProblem.popCount = 2;
        [self.navigationController pushViewController:orderProblem animated:YES];
        
       
        
    }
    if(button.tag == 2){

        [self getOrderFrom];
    }
    
    if(button.tag == 3){
        //改约
        OppoinViewController *orderOppion = [story instantiateViewControllerWithIdentifier:@"appion_opp"];
        orderOppion.serviceNo = _orderd[@"serviceNo"];
        orderOppion.type = @"1";
        [self.navigationController pushViewController:orderOppion animated:YES];
    }
    if(button.tag == 4){
        
        PickUpViewController *orderPickup = [story instantiateViewControllerWithIdentifier:@"pick_up_opp"];
        orderPickup.serviceNo = _orderd[@"serviceNo"];
        [self.navigationController pushViewController:orderPickup animated:YES];
    }
    if(button.tag == 5){
        //预约
        OppoinViewController *orderOppion = [story instantiateViewControllerWithIdentifier:@"appion_opp"];
        orderOppion.serviceNo = _orderd[@"serviceNo"];
        orderOppion.type = @"0";
        [self.navigationController pushViewController:orderOppion animated:YES];
    }
    //[self presentViewController:orderProblem animated:YES completion:nil];
    
    if (button.tag == 77) {
        //抢单
        [self sendData:_orderd[@"serviceNo"]];
    }
    if (button.tag == 88) {
        //核销
        [self getOrderFrom2];
    }
}
- (void)showDialog{
    UIDatePicker *datePicker = [[UIDatePicker alloc] init];
    datePicker.datePickerMode = UIDatePickerModeDateAndTime;
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"\n\n\n\n\n\n\n\n\n\n\n\n" message:nil 　　preferredStyle:UIAlertControllerStyleActionSheet];
    float subWidget = alert.view.frame.size.width;
    float chWidget = datePicker.frame.size.width;
    datePicker.frame = CGRectMake(0, 0, ScreenWidth, datePicker.frame.size.height);
    alert.view.frame = CGRectMake(alert.view.frame.origin.x, alert.view.frame.origin.y, ScreenWidth, alert.view.frame.size.height);
    [alert.view addSubview:datePicker];
    UIAlertAction *ok = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
        NSDateFormatter* dateFormat = [[NSDateFormatter alloc] init];
        //实例化一个NSDateFormatter对象
        [dateFormat setDateFormat:@"yyyy-MM-dd"];//设定时间格式
        NSString *dateString = [dateFormat stringFromDate:datePicker.date];
        //求出当天的时间字符串
        NSLog(@"%@",dateString);
    }];
    UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
        　 }];
    [alert addAction:ok];
    [alert addAction:cancel];
    [self presentViewController:alert animated:YES completion:^{ }];
}

-(void)getData{
    [MBProgressHUD showMessage:@"获取数据"];
    
    NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
    [dic setObject:_serviceNo forKey:@"serviceNo"];
    [dic setObject:[UserDefaultUtil getUserId] forKey:@"identifier"];
    
    HttpReauestParam *param = [[HttpReauestParam alloc] initWithData:@"order_details_get" content:[self dictionaryToJson:dic] urlType:0];
    AFHTTPRequestOperationManager *manage = [AFHTTPRequestOperationManager manager];
    manage.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manage POST:param.SEVICE_URL parameters:param.param success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSDictionary *data = [NSJSONSerialization JSONObjectWithData:operation.responseData options:0 error:nil];
        
        NSLog(@"%@",data);
        [MBProgressHUD hideHUD];
        if([data[@"success"] boolValue]){
            NSString *content = data[@"result"];
            
            NSLog(@"%@",content);
            NSDictionary *orderd = [NSJSONSerialization JSONObjectWithData:[content dataUsingEncoding:NSUTF8StringEncoding] options:0 error:nil];
            _orderd = orderd;
            _detailHeight = [self setTheScrollView:orderd];
            if (_isGrab) {
                //抢单
                [self setTheBottomView4:orderd];
            }else{
                if ([orderd[@"serviceStatus"] isEqualToString:@"待预约"]) {
                    [self setTheBottomView2:orderd];
                }else if([orderd[@"serviceStatus"] isEqualToString:@"待提货"] || [orderd[@"serviceStatus"] isEqualToString:@"待签收"]){
                    [self setTheBottomView:orderd];
                }else if([orderd[@"hxStatus"] integerValue] == 0){
                    [self setTheBottomView5:orderd];
                }else{
                    [self setTheBottomView3:orderd];
                }
            }
            
            [self getNodeData];
        }else{
            [MBProgressHUD showError:data[@"errorMsg"]];
        }
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
    }];
}

-(void)getNodeData{
    
    
    NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
    [dic setObject:_serviceNo forKey:@"serviceNo"];
    [dic setObject:[UserDefaultUtil getUserId] forKey:@"identifier"];
    
    HttpReauestParam *param = [[HttpReauestParam alloc] initWithData:@"order_nodeInfo_get" content:[self dictionaryToJson:dic] urlType:0];
    AFHTTPRequestOperationManager *manage = [AFHTTPRequestOperationManager manager];
    manage.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manage POST:param.SEVICE_URL parameters:param.param success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSDictionary *data = [NSJSONSerialization JSONObjectWithData:operation.responseData options:0 error:nil];
        
        NSLog(@"%@",data);
        
        if([data[@"success"] boolValue]){
            NSString *content = data[@"result"];
            
            NSLog(@"%@",content);
            _nodeData = [NSJSONSerialization JSONObjectWithData:[content dataUsingEncoding:NSUTF8StringEncoding] options:0 error:nil];
            [self setTheNodeView:_detailHeight];
            
            
        }else{
            [MBProgressHUD showError:data[@"errorMsg"]];
        }
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
    }];
}

-(NSString*)dictionaryToJson:(id)dic

{
    
    NSError *parseError = nil;
    
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:&parseError];
    
    return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    
}


/**
 *颜色值转换成图片
 */

- (UIImage*) createImageWithColor: (UIColor*) color
{
    CGRect rect=CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, [color CGColor]);
    CGContextFillRect(context, rect);
    UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    
    return theImage;
}
-(void)getOrderFrom{
    
    if (_hxContent == 0 && _canVerification && _hxResult != 1) {
        
        [self addCNDialog];
        return;
    }
    _hxResult = -1;
    NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
    [dic setObject:_serviceNo forKey:@"serviceNo"];
    [dic setObject:[UserDefaultUtil getUserId] forKey:@"identifier"];
    
    HttpReauestParam *param = [[HttpReauestParam alloc] initWithData:@"order_source_operator" content:[self dictionaryToJson:dic] urlType:0];
    AFHTTPRequestOperationManager *manage = [AFHTTPRequestOperationManager manager];
    manage.responseSerializer = [AFHTTPResponseSerializer serializer];
    [MBProgressHUD showMessage:@"核销验证"];
    [manage POST:param.SEVICE_URL parameters:param.param success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSDictionary *data = [NSJSONSerialization JSONObjectWithData:operation.responseData options:0 error:nil];
        
        NSLog(@"%@",data);
        [MBProgressHUD hideHUD];
        if([data[@"success"] boolValue]){
            NSString *content = data[@"result"];
            
            NSLog(@"%@",content);
            NSDictionary *fromData = [NSJSONSerialization JSONObjectWithData:[content dataUsingEncoding:NSUTF8StringEncoding] options:0 error:nil];
            if ([fromData[@"status"] integerValue] == 0) {
                //未核销
                if ([fromData[@"ifTms"] isEqualToString:@"1"] || [fromData[@"ifTms"] isEqualToString:@"4"] ) {
                    //天猫
                    NSDictionary *params = @{
                                             @"tpId":@"1706441746", //服务商标识
                                             @"outId":fromData[@"outerId"], //内部订单号
                                             @"orderIds":fromData[@"orderId"], //天猫父订单号，多个用逗号分隔
                                             @"serviceType": fromData[@"serviceType"]//服务类型，0：家装的送货上门并安装，1：单向安装，2：建材的送货上门，3：建材的安装，4：建材的送货上门和安装
                                             }; 
                    //fromData[@"serviceType"]
                    
                    [[NSNotificationCenter defaultCenter] addObserver:self
                                                             selector:@selector(callback:)
                                                                 name:MSFIdentifyResultNotification
                                                               object:nil];
                    self.navigationController.navigationBarHidden = NO;
                    [MSFSDK callMSF:params navigationController:self.navigationController];
                    _hxContent = 0;
                }else if ([fromData[@"ifTms"] isEqualToString:@"5"] || [fromData[@"ifTms"] isEqualToString:@"6"] ) {
                    
                    //极有家
                    if ([fromData[@"serviceType"] integerValue] != 0) {
                        NSDictionary *params = @{
                                                 @"tpId":@"1706441746", //服务商标识
                                                 @"outId":fromData[@"outerId"], //内部订单号
                                                 @"orderIds":fromData[@"orderId"], //天猫父订单号，多个用逗号分隔
                                                 @"serviceType": fromData[@"serviceType"]//服务类型，0：家装的送货上门并安装，1：单向安装，2：建材的送货上门，3：建材的安装，4：建材的送货上门和安装
                                                 };
                        //fromData[@"serviceType"]
                        
                        
                        
                        [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(callback:) name:MSFIdentifyResultNotification object:nil];
                        self.navigationController.navigationBarHidden = NO;
                        [MSFSDK callMSF:params navigationController:self.navigationController];
                        _hxContent = 0;
                    }else{
                        UIStoryboard *story = [UIStoryboard storyboardWithName:@"App_Main" bundle:[NSBundle mainBundle]];
                        SignViewController *orderSign = [story instantiateViewControllerWithIdentifier:@"sign_opp"];
                        orderSign.serviceNo = _orderd[@"serviceNo"];
                        orderSign.popCount = 2;
                        orderSign.receiveNoType = _receiveNoType;
                        orderSign.shopNoType = _shopNoType;
                        orderSign.hxResult = _hxResult;
                        [self.navigationController pushViewController:orderSign animated:YES];
                    }
                    
                }else{
                    
                    if([fromData[@"ifTms"] isEqualToString:@"2"]){
                        [MBProgressHUD showError:@"友情提示:改订单未核销，请联系京东核销"];
                    }
                    UIStoryboard *story = [UIStoryboard storyboardWithName:@"App_Main" bundle:[NSBundle mainBundle]];
                    SignViewController *orderSign = [story instantiateViewControllerWithIdentifier:@"sign_opp"];
                    orderSign.serviceNo = _orderd[@"serviceNo"];
                    orderSign.popCount = 2;
                    orderSign.receiveNoType = _receiveNoType;
                    orderSign.shopNoType = _shopNoType;
                    orderSign.hxResult = _hxResult;
                    [self.navigationController pushViewController:orderSign animated:YES];
                }
            }else if([fromData[@"status"] integerValue] == 1){
                _hxResult = 1;
                //已核销
                UIStoryboard *story = [UIStoryboard storyboardWithName:@"App_Main" bundle:[NSBundle mainBundle]];
                SignViewController *orderSign = [story instantiateViewControllerWithIdentifier:@"sign_opp"];
                orderSign.serviceNo = _orderd[@"serviceNo"];
                orderSign.popCount = 2;
                orderSign.receiveNoType = _receiveNoType;
                orderSign.shopNoType = _shopNoType;
                orderSign.hxResult = _hxResult;
                [self.navigationController pushViewController:orderSign animated:YES];
            }else{
                UIStoryboard *story = [UIStoryboard storyboardWithName:@"App_Main" bundle:[NSBundle mainBundle]];
                SignViewController *orderSign = [story instantiateViewControllerWithIdentifier:@"sign_opp"];
                orderSign.serviceNo = _orderd[@"serviceNo"];
                orderSign.popCount = 2;
                orderSign.receiveNoType = _receiveNoType;
                orderSign.shopNoType = _shopNoType;
                orderSign.hxResult = _hxResult;
                [self.navigationController pushViewController:orderSign animated:YES];
            }
            
            
            
        }else{
            [MBProgressHUD showError:data[@"errorMsg"]];
        }
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [MBProgressHUD hideHUD];
    }];
}

-(void)getOrderFrom2{
    
    NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
    [dic setObject:_serviceNo forKey:@"serviceNo"];
    [dic setObject:[UserDefaultUtil getUserId] forKey:@"identifier"];
    
    HttpReauestParam *param = [[HttpReauestParam alloc] initWithData:@"order_source_operator" content:[self dictionaryToJson:dic] urlType:0];
    AFHTTPRequestOperationManager *manage = [AFHTTPRequestOperationManager manager];
    manage.responseSerializer = [AFHTTPResponseSerializer serializer];
    [MBProgressHUD showMessage:@"核销验证"];
    [manage POST:param.SEVICE_URL parameters:param.param success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSDictionary *data = [NSJSONSerialization JSONObjectWithData:operation.responseData options:0 error:nil];
        
        NSLog(@"%@",data);
        [MBProgressHUD hideHUD];
        if([data[@"success"] boolValue]){
            NSString *content = data[@"result"];
            
            NSLog(@"%@",content);
            NSDictionary *fromData = [NSJSONSerialization JSONObjectWithData:[content dataUsingEncoding:NSUTF8StringEncoding] options:0 error:nil];
            if ([fromData[@"status"] integerValue] == 0) {
                //未核销
                if ([fromData[@"ifTms"] isEqualToString:@"1"] || [fromData[@"ifTms"] isEqualToString:@"4"] ) {
                    //天猫
                    NSDictionary *params = @{
                                             @"tpId":@"1706441746", //服务商标识
                                             @"outId":fromData[@"outerId"], //内部订单号
                                             @"orderIds":fromData[@"orderId"], //天猫父订单号，多个用逗号分隔
                                             @"serviceType": fromData[@"serviceType"]//服务类型，0：家装的送货上门并安装，1：单向安装，2：建材的送货上门，3：建材的安装，4：建材的送货上门和安装
                                             };
                    //fromData[@"serviceType"]
                    
                    [[NSNotificationCenter defaultCenter] addObserver:self
                                                             selector:@selector(callback:)
                                                                 name:MSFIdentifyResultNotification
                                                               object:nil];
                    self.navigationController.navigationBarHidden = NO;
                    [MSFSDK callMSF:params navigationController:self.navigationController];
                    _hxContent = 0;
                }else if ([fromData[@"ifTms"] isEqualToString:@"5"] || [fromData[@"ifTms"] isEqualToString:@"6"] ) {
                    
                    //极有家
                    if ([fromData[@"serviceType"] integerValue] != 0) {
                        NSDictionary *params = @{
                                                 @"tpId":@"1706441746", //服务商标识
                                                 @"outId":fromData[@"outerId"], //内部订单号
                                                 @"orderIds":fromData[@"orderId"], //天猫父订单号，多个用逗号分隔
                                                 @"serviceType": fromData[@"serviceType"]//服务类型，0：家装的送货上门并安装，1：单向安装，2：建材的送货上门，3：建材的安装，4：建材的送货上门和安装
                                                 };
                        //fromData[@"serviceType"]
                        
                        
                        
                        [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(callback:) name:MSFIdentifyResultNotification object:nil];
                        self.navigationController.navigationBarHidden = NO;
                        [MSFSDK callMSF:params navigationController:self.navigationController];
                        _hxContent = 0;
                    }
                }
            }
            
            
            
        }else{
            [MBProgressHUD showError:data[@"errorMsg"]];
        }
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [MBProgressHUD hideHUD];
    }];
}
- (void)callback:(NSNotification *)notification
{
    
    NSDictionary *userInfo = notification.userInfo;
    //userInfo包括三个属性
    //signsuccess  签到是否成功，1：成功，0：不成功
    //verifysuccess 核销是否成功，1：成功，0：不成功
    //imgpath  核销图片地址， 多个图片以逗号分隔
    NSNumber *verifysuccess = [userInfo objectForKey:@"verifysuccess"];
    if ([verifysuccess boolValue]) {
        //TODO Success Operation
        NSLog(@"核销成功了");
        if (_hxContent == 0) {
            _hxContent = 1;
            _hxResult = 1;
            if ([_orderd[@"serviceStatus"] isEqualToString:@"待签收"]) {
                [self sendHX];
            }else{
                [self sendHX2];
            }
            
        }
        
    }else if(_canVerification){
        //核销失败
        UIStoryboard *story = [UIStoryboard storyboardWithName:@"App_Main" bundle:[NSBundle mainBundle]];
        FaildViewController *faildVc= [story instantiateViewControllerWithIdentifier:@"hx_faild_view"];
        faildVc.serviceNo = _orderd[@"serviceNo"];
        [self.navigationController pushViewController:faildVc animated:YES];
    }
}

-(void)sendHX{
    
    NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
    [dic setObject:_serviceNo forKey:@"serviceNo"];
    [dic setObject:[UserDefaultUtil getUserId] forKey:@"identifier"];
    
    HttpReauestParam *param = [[HttpReauestParam alloc] initWithData:@"mao_hx_notice" content:[self dictionaryToJson:dic] urlType:0];
    AFHTTPRequestOperationManager *manage = [AFHTTPRequestOperationManager manager];
    manage.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manage POST:param.SEVICE_URL parameters:param.param success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        //核销成功
        UIStoryboard *story = [UIStoryboard storyboardWithName:@"App_Main" bundle:[NSBundle mainBundle]];
        SignViewController *orderSign = [story instantiateViewControllerWithIdentifier:@"sign_opp"];
        orderSign.serviceNo = _orderd[@"serviceNo"];
        orderSign.popCount = 2;
        orderSign.receiveNoType = _receiveNoType;
        orderSign.shopNoType = _shopNoType;
        orderSign.hxResult = _hxResult;
        [self.navigationController pushViewController:orderSign animated:YES];

        
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        //核销成功
        UIStoryboard *story = [UIStoryboard storyboardWithName:@"App_Main" bundle:[NSBundle mainBundle]];
        SignViewController *orderSign = [story instantiateViewControllerWithIdentifier:@"sign_opp"];
        orderSign.serviceNo = _orderd[@"serviceNo"];
        orderSign.receiveNoType = _receiveNoType;
        orderSign.shopNoType = _shopNoType;
        orderSign.hxResult = _hxResult;
        [self.navigationController pushViewController:orderSign animated:YES];

        
    }];
}
-(void)sendHX2{
    
    NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
    [dic setObject:_serviceNo forKey:@"serviceNo"];
    [dic setObject:[UserDefaultUtil getUserId] forKey:@"identifier"];
    
    HttpReauestParam *param = [[HttpReauestParam alloc] initWithData:@"mao_hx_notice" content:[self dictionaryToJson:dic] urlType:0];
    AFHTTPRequestOperationManager *manage = [AFHTTPRequestOperationManager manager];
    manage.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manage POST:param.SEVICE_URL parameters:param.param success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        
        
        
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
    }];
}


-(void) sendData:(NSString *) serviceNo{
    
    NSString *userId =[UserDefaultUtil getUserId];
    NSDictionary * dic = @{@"identifier": userId ,@"serviceNo":serviceNo};
    
    
    HttpReauestParam * param = [[HttpReauestParam alloc]initWithData:@"order_grab_operator" content:[self dictionaryToJson:dic] urlType:0];
    AFHTTPRequestOperationManager *manage = [AFHTTPRequestOperationManager manager];
    manage.responseSerializer = [AFHTTPResponseSerializer serializer];
    [MBProgressHUD showMessage:@"抢单"];
    [manage POST:param.SEVICE_URL parameters:param.param success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSDictionary * data = [NSJSONSerialization JSONObjectWithData:operation.responseObject options:0 error:nil];
        [MBProgressHUD hideHUD];
        
        if ([data[@"success"] boolValue]) {
            
            [MBProgressHUD showSuccess:@"抢单成功"];
            
        
            [self getData];
        }else{
            [MBProgressHUD showError:data[@"errorMsg"]];
        }
        [MBProgressHUD hideHUD];
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [MBProgressHUD hideHUD];
        [MBProgressHUD showError:@"网络连接失败"];
    }];
}

-(void)addTicket{
    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"App_Main" bundle:[NSBundle mainBundle]];
    
    TicketViewController *ticket = [sb instantiateViewControllerWithIdentifier:@"ticket_view"];
    ticket.popCount = 2;
    ticket.serviceNo = _serviceNo;
    ticket.receiveNoType = _receiveNoType;
    ticket.shopNoType = _shopNoType;
    [self.navigationController pushViewController:ticket animated:YES];
}


-(void)addCNDialog{
    UIControl *dialog = [self.view viewWithTag:777];
    if (dialog == nil) {
        dialog = [[UIControl alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
        dialog.tag = 777;
        dialog.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];;
        [dialog addTarget:self action:@selector(touch_dialog:) forControlEvents:UIControlEventTouchUpInside];
        
        UIButton *sign = [[UIButton alloc]initWithFrame:CGRectMake(20, ScreenHeight / 2 - 45, ScreenWidth - 40, 45)];
        [sign setTitle:@"签收" forState:UIControlStateNormal];
        sign.titleLabel.font = [UIFont systemFontOfSize:13];
        sign.backgroundColor = [UIColor whiteColor];
        [sign setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [sign setTitleColor:[UIColor lightGrayColor] forState:UIControlStateSelected];
        sign.tag = 0;
        [sign addTarget:self action:@selector(click_dialog:) forControlEvents:UIControlEventTouchUpInside];
        [dialog addSubview:sign];
        
        UIButton *hx = [[UIButton alloc]initWithFrame:CGRectMake(20, ScreenHeight / 2 + 1, ScreenWidth - 40, 45)];
        [hx setTitle:@"核销" forState:UIControlStateNormal];
        hx.titleLabel.font = [UIFont systemFontOfSize:13];
        hx.backgroundColor = [UIColor whiteColor];
        [hx setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [hx setTitleColor:[UIColor lightGrayColor] forState:UIControlStateSelected];
        [hx addTarget:self action:@selector(click_dialog:) forControlEvents:UIControlEventTouchUpInside];
        hx.tag = 1;
        [dialog addSubview:hx];
        
        
        [self.view addSubview:dialog];
        
    }else{
        if (dialog.hidden) {
            dialog.hidden = NO;
        }else{
            dialog.hidden = YES;
        }
        
    }
}


-(void)touch_dialog:(UIControl *)control{
    if (!control.hidden) {
        control.hidden = YES;
    }
}

-(void)click_dialog:(UIButton *)btn{
    
    UIControl *control = [self.view viewWithTag:777];
    control.hidden = YES;
    int tag = btn.tag;
    if (tag == 0) {
        //签收
        //核销失败
        UIStoryboard *story = [UIStoryboard storyboardWithName:@"App_Main" bundle:[NSBundle mainBundle]];
        FaildViewController *faildVc= [story instantiateViewControllerWithIdentifier:@"hx_faild_view"];
        faildVc.serviceNo = _orderd[@"serviceNo"];
        faildVc.hxResult = _hxResult;
        [self.navigationController pushViewController:faildVc animated:YES];
        
    }else if(tag == 1){
        _hxContent = -1;
        [self getOrderFrom];
    }
}
@end
